package com.jrzh.db.migration.sys;

import com.eroi.migrate.Define;
import com.jrzh.framework.migration.BaseMigration;
import com.jrzh.framework.migration.MigrationHelper;

public class Migration_26 extends BaseMigration{

	private static final String TABLE_NAME = "sys_table_name";
	private static final String TABLE_NAME_ONE = "sys_table_fields";
	private static final String TABLE_NAME_TWO = "sys_table_history";
	
	@Override
	public void down() {
		MigrationHelper.dropTable(TABLE_NAME);
		MigrationHelper.dropTable(TABLE_NAME_ONE);
		MigrationHelper.dropTable(TABLE_NAME_TWO);
	}

	@Override
	public void up() {
		log.info("##########执行Sys模块 Migration_26##########Begin");
		table(TABLE_NAME, "系统表格信息", true,
				pk(),
				column("_table_name", "表格名称", Define.DataTypes.VARCHAR, Define.length(128)),
				column("_is_show", "是否显示", Define.DataTypes.VARCHAR, Define.length(10)),
				column("_is_tree", "是否包含树形字段", Define.DataTypes.VARCHAR, Define.length(10)),
				column("_is_wf", "是否工作流", Define.DataTypes.VARCHAR, Define.length(10)),
				column("_comment", "注释", Define.DataTypes.VARCHAR, Define.length(9999))
		);
		table(TABLE_NAME_ONE, "系统表格字段信息", true,
				pk(),
				column("_table_id", "表格ID", Define.DataTypes.VARCHAR, Define.length(128)),
				column("_field_key", "字段key", Define.DataTypes.VARCHAR, Define.length(254)),
				column("_field_type", "字段类型", Define.DataTypes.VARCHAR, Define.length(128)),
				column("_is_null", "是否允许为空", Define.DataTypes.VARCHAR, Define.length(10)),
				column("_default", "默认值", Define.DataTypes.VARCHAR, Define.length(999)),
				column("_comment", "注释", Define.DataTypes.VARCHAR, Define.length(9999))
		);
		table(TABLE_NAME_TWO, "系统表格字段管理历史", true,
				pk(),
				column("_table_id", "表格ID", Define.DataTypes.VARCHAR, Define.length(128)),
				column("_table_name", "表格名称", Define.DataTypes.VARCHAR, Define.length(128)),
				column("_opration_type", "操作类型", Define.DataTypes.VARCHAR, Define.length(128)),
				column("_sql", "sql语句", Define.DataTypes.VARCHAR, Define.length(9999))
		);
		
		log.info("##########执行Sys模块 Migration_26##########End");
	}

}
